package cn.zjitc.service.impl;

import cn.zjitc.dao.LoginDao;
import cn.zjitc.pojo.User;
import cn.zjitc.service.LoginService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;



@Service(interfaceClass = LoginService.class)
@Transactional
public class LoginServiceImpl implements LoginService {
    @Autowired
    private LoginDao loginDao;
    @Override
    public void regist(String user_name, String user_password) {
        User u = new User();
        u.setUser_name(user_name);
        u.setUser_password(user_password);
        loginDao.regist(u);

        Integer id=loginDao.findIdByUserName(u.getUser_name());
        loginDao.registborrow(id);
    }

    @Override
    public User login(String username, String password) {
        User u = new User();
        u.setUser_name(username);
        u.setUser_password(password);
        User user =loginDao.login(u);
        return user;
    }

    @Override
    public User findByUserName(String user_name) {
        User user = new User();
        user.setUser_name(user_name);
        return loginDao.findByUserName(user);
    }
}
